import React from 'react'
import { connect } from 'react-redux'
import { sub } from '../actions/countAction'

class CounterSub extends React.Component {
  render() {
    return (
      <div>
        <h3>当前最新的Count值为：{this.props.count}</h3>
        <button onClick={this.props.Decrement}>-1</button>
      </div>
    )
  }
}

function mapStateToProps(state) {
  return {
    count: state.count
  }
}

function mapDispatchToProps(dispatch) {
  return {
    Decrement: () => dispatch(sub(1))
  }
}

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(CounterSub)
